/*=========================================================================
The Impact of Denying a Wanted Abortion on Women and Children
Authors: Juliana Londoño-Vélez and Estefanía Saravia

Creation date: January 9th, 2024
--------------------------------------------------------------------------
Table 4 - Test of Random Claim Assignment to Judges
=========================================================================*/

use "$data/Final_Medellin_SisbenIII.dta", replace


keep if Caso_Aborto ==1

global outcomes Edad_Encuesta Edad_Tutela Embarazo_adolescente  Nivel_0 Primaria Secundaria Media Superior puntaje_float Estrato_0_1 thogar Numero_Hijos Any_Children Soltera Casada Separada Viuda Cabecera


mat a=J(20,6,.)

matrix rownames a =  $outcomes "F-stat" "p-value"



local i=1

foreach var in $outcomes {

reghdfe `var' i.id_juez, abs(oficina#time) 
	mat a[`i',3]=e(N)
	testparm i.id_juez

	mat a[`i',1]=`r(F)'
	mat a[`i',2]=`r(p)'
	
	local i=`i'+1
	}
	
	
reghdfe id_juez $outcomes, abs(oficina#time)
testparm $outcomes


mat a[19,1]=`r(F)'
mat a[20,2]=`r(p)'	
	
	
	
svmat2 a, rnames(outcome)
	
	
	drop if outcome==""
	
	rename a1 F_stat
	rename a2 p_value
	rename a3 N

	
	
	keep outcome F_stat  p_value N
	
	order outcome F_stat  p_value N
	
	
	export excel using "$output/Tables paper matrices replication.xlsx", sheet("Table 4", modify) 
